package maze.view;

import maze.app.Maze;
import maze.model.Map;
import maze.model.Pair;

import org.lwjgl.opengl.GL11;

public class TargetSprite extends Sprite
{
	public TargetSprite()
	{
		super("target");

		init();
	}

	@Override
	public void init()
	{
		randomPosition(new Pair(0, 0));
	}

	public void randomPosition(Pair originalPos)
	{
		do
		{
			pos = Map.getInstance().randomPosition();
		} while (pos.equals(originalPos));
	}

	@Override
	public void render()
	{
		GL11.glPushMatrix();

		// leave the blank for each side
		GL11.glTranslatef(Maze.BLANK_UNIT, Maze.BLANK_UNIT, 0.0f);

		GL11.glTranslatef((pos.x + 0.5f) * Maze.UNIT, (pos.y + 0.5f) * Maze.UNIT, 0.0f);

		drawTexture();

		GL11.glPopMatrix();
	}
}
